package exam.demo16;

import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        String str = in.next();
        int n = in.nextInt();

        int[] arr = new int[str.length() - n];
        for(int i = 0; i < str.length() - n; i++) {
            int count = 0;
            for(int j = 0; j < n; j++) {
                if(str.charAt(i + j) == 'C' || str.charAt(i + j) == 'G') {
                    count++;
                }
            }
            arr[i] = count;
        }
        int max = 0;
        int index = 0;
        for(int i = 0; i < str.length() - n; i++) {
            if(arr[i] > max) {
                max = arr[i];
                index = i;
            }
        }
        String str1 = str.substring(index, max + index + 1);
        System.out.println(str1);
    }
}
